//
//  ChoicePlantTypeCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/1/9.
//

#import "ChoicePlantTypeCell.h"
@interface ChoicePlantTypeCell ()
@property (nonatomic ,strong) QMUILabel *titleLab;

@property (nonatomic ,strong) QMUILabel *devIdLab;

@property (nonatomic ,strong) QMUILabel *devStateLab;

@property (nonatomic ,strong) UIImageView *markView;

@end
@implementation ChoicePlantTypeCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}



- (void)setupUI{
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setFont:kBOLDSYSTEMFONT(14)];
    [_titleLab setTextColor:FontColor(@"#3F4443")];
    [self.contentView addSubview:_titleLab];
//    _titleLab.backgroundColor = UIColor.redColor;
    
    _devIdLab = [[QMUILabel alloc] init];
    [_devIdLab setTextAlignment:NSTextAlignmentCenter];
    [_devIdLab setFont:kSYSTEMFONT(14)];
    [_devIdLab setTextColor:FontColor(@"#3F4443")];
    [self.contentView addSubview:_devIdLab];
//    _devIdLab.backgroundColor = UIColor.yellowColor;
    
//    _devStateLab = [[QMUILabel alloc] init];
//    [_devStateLab setTextAlignment:NSTextAlignmentLeft];
//    [_devStateLab setFont:[UIFont systemFontOfSize:10]];
//    [_devStateLab setTextColor:FontColor(@"#999999")];
//    [_devStateLab setBackgroundColor:FontColor(@"#999999")];
//    [_devStateLab.layer setCornerRadius:4];
//    [_devStateLab.layer setMasksToBounds:YES];
//    [self.contentView addSubview:_devStateLab];
    
    _markView = [[UIImageView alloc] init];
    [_markView setBackgroundColor:UIColor.clearColor];
    [self.contentView addSubview:_markView];
    //[_markView setImage:[UIImage imageNamed:@"choice_ok"]];
    
    kWeakSelf;
    
//    [_devStateLab mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.mas_equalTo(CGSizeMake(8, 8));
//        make.left.mas_offset(10);
//        make.centerY.equalTo(weakSelf.titleLab);
//    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(22);
        make.width.offset(80);
        make.centerY.mas_offset(0);
    }];
    
    [_devIdLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.centerY.mas_offset(0);
    }];
    
    [_markView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.right.mas_offset(-22);
        make.centerY.mas_offset(0);
    }];
    
}


- (void)setPlantTypeModel:(RHPlantTypeModel *)plantTypeModel
{
    _plantTypeModel = plantTypeModel;
    
    _devIdLab.text = plantTypeModel.plantType;
    _devIdLab.textAlignment = NSTextAlignmentCenter;
  
}

- (void)setIsSelect:(BOOL)isSelect{
    _isSelect = isSelect;
    [_markView setImage:[UIImage imageNamed:_isSelect?@"agree":@""]];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
